package com.smag.web.controller.echarts.map;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.smag.common.utils.poi.ExcelUtil;
import com.smag.echarts.domain.EchartsMap;
import com.smag.echarts.service.IEchartsMapService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.smag.common.annotation.Log;
import com.smag.common.core.controller.BaseController;
import com.smag.common.core.domain.AjaxResult;
import com.smag.common.enums.BusinessType;
import com.smag.common.core.page.TableDataInfo;

/**
 * 广西地图各市数据Controller
 *
 * @author ruoyi
 * @date 2023-04-25
 */
@RestController("mapController")
@RequestMapping("/echarts/map/map")
public class MapController extends BaseController
{
    @Autowired
    private IEchartsMapService echartsMapService;

    @RequestMapping("/allList")
    public AjaxResult allList(){
        return success(echartsMapService.allList());
    }

    /**
     * 查询广西地图各市数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:map:list')")
    @GetMapping("/list")
    public TableDataInfo list(EchartsMap echartsMap)
    {
        startPage();
        List<EchartsMap> list = echartsMapService.selectEchartsMapList(echartsMap);
        return getDataTable(list);
    }

    /**
     * 导出广西地图各市数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:map:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EchartsMap echartsMap)
    {
        List<EchartsMap> list = echartsMapService.selectEchartsMapList(echartsMap);
        ExcelUtil<EchartsMap> util = new ExcelUtil<EchartsMap>(EchartsMap.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取广西地图各市数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:map:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(echartsMapService.selectEchartsMapById(id));
    }

    /**
     * 新增广西地图各市数据
     */
    @PreAuthorize("@ss.hasPermi('system:map:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EchartsMap echartsMap)
    {
        return toAjax(echartsMapService.insertEchartsMap(echartsMap));
    }

    /**
     * 修改广西地图各市数据
     */
    @PreAuthorize("@ss.hasPermi('system:map:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EchartsMap echartsMap)
    {
        return toAjax(echartsMapService.updateEchartsMap(echartsMap));
    }

    /**
     * 删除广西地图各市数据
     */
    @PreAuthorize("@ss.hasPermi('system:map:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(echartsMapService.deleteEchartsMapByIds(ids));
    }
}
